package com.hdax.dm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.exceptions.DmException;
import com.hdax.dm.exceptions.constant.ErrConstant;
import com.hdax.dm.mappers.LinkUserMapper;
import com.hdax.dm.mappers.UserMapper;
import com.hdax.dm.service.LinkUserService;
import com.hdax.dm.service.UserService;
import com.hdax.dm.user.DmLinkUser;
import com.hdax.dm.user.User;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LinkUserServiceImpl extends ServiceImpl<LinkUserMapper, DmLinkUser> implements LinkUserService {


    @Override
    public List<DmLinkUser> userList(Long userid) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.eq("userId",userid);
        List<DmLinkUser> userList = baseMapper.selectList(wrapper);
        return userList;
    }

    @Override
    public Boolean deleteLinkUserId(Long linkId) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.eq("id",linkId);
        return remove(wrapper);
    }

    @Override
    public Boolean validatebuyerexist(String idCard) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("idCard",idCard);
        Boolean b = baseMapper.exists(queryWrapper);
        return b;
    }

    @Override
    public Boolean addticketbuyer(DmLinkUser user) {
       int count = baseMapper.insert(user);
        return count ==1 ?true:false;
    }

    @Override
    public List<DmLinkUser> userListId(Long id) {
        QueryWrapper wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        return list(wrapper);
    }




}
